# -*- coding: utf-8 -*-
from odoo import api, fields, models
from odoo.exceptions import ValidationError


class SaleAdvancePaymentInvInherit(models.TransientModel):
    _inherit = 'sale.advance.payment.inv'

    taiwan_invoice = fields.Char(string='發票號碼')
    invoice_type = fields.Selection(selection=[(1, u'三聯式發票、電子計算機發票'), (2, u'收銀機發票(三聯式)及電子發票'),
                                               (3, u'二聯式發票、收銀機發票(二聯式)'), (4, u'減:退回及折讓')],
                                    string='發票類型', default=3)

    @api.multi
    def _create_invoice(self, order, so_line, amount):
        res = super(SaleAdvancePaymentInvInherit, self)._create_invoice(order, so_line, amount)
        res.write({
            'taiwan_invoice': self.taiwan_invoice,
            'invoice_type': self.invoice_type
        })
        return res



